//
// Created by NASA on 2024-5-25
// 高精度计算--subtract减法
// OJ:https://www.luogu.com.cn/problem/P2142 pass
// OJ:http://ybt.ssoier.cn:8088/problem_show.php?pid=1169 pass
//


/*
 * 99-99=0
 * 22-11=11
 * 111-12=99
 * 166-32=134
 * 11-122=-111
 * 111-122=-11
 * 30141-8160=21981
 * 12-14=-2
 */
#include <iostream>

using namespace std;

string subtractTwoString(string a, string b)
{
    if(a==b)
    {
        return "0";
    }
    bool negative = false;
    string s, s1;
    if (a.size() < b.size())
    {
        negative = true;
        swap(a, b);
    } else if (a.size() == b.size())
    {
        for (int i = 0; i < a.size(); ++i)
        {
            if ((a[i] - '0') < (b[i] - '0'))
            {
                negative = true;
                swap(a, b);
                break;
            } else if ((a[i] - '0') > (b[i] - '0'))
            {
                break;
            }
        }
    }
    while (a.size() != b.size())
    {
        if (a.size() > b.size())
        {
            b = "0" + b;
        } else
        {
            a = "0" + a;
        }
    }
    for (int i = 0; i < a.size(); ++i)
    {

    }
    int l[a.size()];
    for (int i = a.size() - 1; i >= 0; --i)
    {
        l[i] = (a[i] - '0') - (b[i] - '0');
    }
    for (int i = a.size() - 1; i >= 0; --i)
    {
        if (l[i] >= 0)
        {
            s = to_string(l[i]) + s;
        } else
        {
            s = to_string(l[i] + 10) + s;
            l[i - 1]--;
        }
    }
    int i;
    for (i = 0; i < s.size(); ++i)
    {
        if (s[i] != '0')
        {
            break;
        }
    }
    for (; i < s.size(); ++i)
    {
        s1.push_back(s[i]);
    }
    if (negative)
    {
        s1 = "-" + s1;
    }
    return s1;
}

int main()
{
    // a-b
    string a = "112", b = "100"; // 12
    a = "212", b = "103"; // 109
    a = "99", b = "99"; //0
//    a = "11", b = "122";  // -111
//    a = "111", b = "122"; // -11
//    a = "30141", b = "8160"; //21981
//    a = "8160", b = "30141"; //-21981
//    a = "12", b = "14";  // -2
//    cin>>a>>b;
    cout << subtractTwoString(a, b);
    return 0;
}